package com.example.demo;

import com.example.demo.socket.SocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;

@EnableJpaAuditing
@EnableAsync
@SpringBootApplication(scanBasePackages = "com.example")
public class DemoApplication {

    @Autowired
    private SocketServer socketServer;

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);

    }

    @EventListener(WebServerInitializedEvent.class)
    public void onWebServerReady(WebServerInitializedEvent event) {
        socketServer.start();
    }

}
